<script type="text/javascript">
var counter=1;
function hapus_row(obj){	
	 if (confirm('Apakah data akan dihapus ?')) {
  		obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
	}
}
function add_row_komp(id_komp,nama_komp) {
        var tombol_aksi = '<a href="javascript:void(null)" title="Hapus" onclick="hapus_row(this)"><button type="button" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></button></a>';
  		var tr = document.createElement('tr');
  		var td_nama_komp = document.createElement('td');
		var td_nominal = document.createElement('td');
		
  		var td_aksi = document.createElement('td');  		
  		var tbodi = document.getElementById("tbody_list_komp");
  		
  		td_aksi.className = 'links';
  		td_aksi.width = 15;
  		
		td_nama_komp.innerHTML = nama_komp+"<input type='hidden' name='id_komp[]' id='id_komp_"+counter+"' value='"+id_komp+"' >";
		td_nominal.innerHTML = "<input type='text' name='nominal[]' onChange=\"rupiah('nominal_"+counter+"')\" id='nominal_"+counter+"' class='form-control input-sm' size='10'>";

  		td_aksi.innerHTML = tombol_aksi;
  		
  		tr.appendChild(td_nama_komp);
		tr.appendChild(td_nominal);

  		tr.appendChild(td_aksi);
  		tbodi.appendChild(tr);
		counter++;
		
}
function rupiah(komp){
$('#'+komp).autoNumeric({
		aSep: '.', 
		aDec: ','}
	);
}
</script>
<!-- komponen Modal -->
<div class="modal fade" id="pop_komponen" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div id="popup_pembayaran"></div>
		</div>
	</div>
</div>
<!-- end komponen modal -->
<div id="page-wrapper">
        <!-- /.row -->
    <div class="row">
        <div class="col-sm-12">
            <div class="panel panel-default">
                <div class="panel-heading"><span class="judul-page">Tambah Komponen Pembayaran Bulanan</span>
				<span class="pull-right">
                        <a href="<?php echo site_url('set_pembayaran_bulanan/index/'.$id_lembaga);?>" class="btn btn-warning btn-xs"><span class="glyphicon glyphicon-plus"></span>&nbsp;Kembali</a>
                </span>
				</div>
                <div class="panel-body">
					<?php 
						echo form_open('set_pembayaran_bulanan/proses_add', array('class' => 'form-horizontal', 'role' => 'form')); 
					?>
						<div class="form-group">
							<label class="col-sm-3 control-label">Tahun Pelajaran</label>
							<div class="col-sm-4">
					<?php $js='class="form-control form-elba input-sm"';

				echo form_dropdown('tapel',$tapel,set_value('tapel'),$js); ?>
				
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Jenis Komponen</label>
							<div class="col-sm-8"><p class="form-control-static">
								<span class="pull-right">
					<a href="#" class="btn btn-warning btn-xs" style="margin-bottom: 5px;" onclick="show_popup()" data-toggle="modal" data-target="#pop_komponen"><span class="glyphicon glyphicon-plus"></span>&nbsp;Tambah Komponen</a>
				</span>
				<!-- <div class="panel-body"> -->
					<table class="table table-striped table-bordered table-hover table-condensed">
						<thead>
							<tr>
								<th>Nama Komponen</th>
								<th width="35%">Nominal</th>
								<th width="40"></th>
							</tr>
						</thead>
						<tbody id="tbody_list_komp">
						</tbody>
					</table>
				<!-- </div> -->
				</p>
							</div>
						</div>
						
                      <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-9">
							<input type="hidden" name="id_lembaga" value="<?php echo $id_lembaga;?>" />
                          <button type="submit" class="btn btn-primary btn-sm">Simpan</button>
                          <button type="reset" class="btn btn-danger btn-sm">Reset</button>
                        </div>
                      </div>
                    <?php 
						echo form_close();
					?>
                </div>
            </div>
        </div>
    </div>
    <!-- /.row -->
</div>
<!-- /#page-wrapper -->
<script type="text/javascript">
    /*$('#saudaraModal').modal(options);
    $('#ortuModal').modal(options);
    $('#editSModal').modal(options);*/	
	
	function show_popup(){
		$.ajax({
			type: "POST",
			url : "<?php echo site_url(); ?>mr_komp_pembayaran/popup_komponen",
			data: "jenis=bulanan",
			cache: false,
			success: function(response) {
				$('#popup_pembayaran').html(response);
			}
		});
		return false;
	}	
</script>